package com.itqf.controller;

import com.google.gson.Gson;
import com.itqf.entity.Type;
import com.itqf.service.TypeSrevice;
import com.itqf.service.impl.TypeServiceImpl;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.SQLException;
import java.util.List;

@WebServlet("/type")
public class TypeController extends BaseServlet{

    public String findAll(HttpServletRequest req, HttpServletResponse resp) throws SQLException {
        TypeSrevice typeSrevice = new TypeServiceImpl();
        List<Type> types = typeSrevice.findAll();
        Gson gson = new Gson();
        String json = gson.toJson(types);
        System.out.println(json);
        return  json;
    }
}
